//
//  EnterView.m
//  Car
//
//  Created by apple on 15/9/22.
//  Copyright (c) 2015年 朱鸿儒. All rights reserved.
//

#import "EnterView.h"

@implementation EnterView

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self setUpView];
        
        
    }
    
    return self;
}


- (void)setUpView {
    
    self.bigView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, kWidth - 40, kHeight - 40 - 64)];
    [self setUpWithBigView:self.bigView];

    self.userNameTextfield = [[UITextField alloc] initWithFrame:CGRectMake(20, self.bigView.frame.size.height/2, kWidth - 80, 55)];
    [self setUpWithTextfield:self.userNameTextfield placeholder:@"                          Login"];
     [self.bigView addSubview:self.userNameTextfield];
    
    self.userPasswordTextfield = [[UITextField alloc] initWithFrame:CGRectMake(20, self.userNameTextfield.frame.origin.y + self.userNameTextfield.frame.size.height, kWidth - 80, 55)];
    [self setUpWithTextfield:self.userPasswordTextfield placeholder:@"                      Password"];
    self.userPasswordTextfield.secureTextEntry = YES;
     [self.bigView addSubview:self.userPasswordTextfield];
    
    //  照片
    self.photoHolderView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 60, 140, 140)];
    self.photoHolderView.center = CGPointMake(self.bigView.frame.size.width / 2, self.bigView.frame.size.height / 4);
    [self setUpWithphotoHolderView:self.photoHolderView];
    
    //  登录按钮
    self.enterButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.enterButton.frame = CGRectMake(0, 0, self.userNameTextfield.frame.size.width / 2, self.userNameTextfield.frame.size.height);
    [self setWithEnterButton:self.enterButton];
    
    
    
}


- (void)setWithEnterButton:(UIButton *)enterButton {
    
    enterButton.center = CGPointMake(self.bigView.frame.size.width / 2 + 20, self.bigView.frame.size.height * 6 / 7);
    
    [enterButton setTitle:@"登录" forState:UIControlStateNormal];
    
    enterButton.backgroundColor = [UIColor colorWithRed:51/255.0f green:161/255.0f blue:201/255.0f alpha:1.0];
    //  圆角
    enterButton.layer.masksToBounds = YES;
    enterButton.layer.cornerRadius = 5;
    
   
    [self addSubview:enterButton];
    
    
}


- (void)setUpWithBigView:(UIView *)bigView {
    
    bigView.backgroundColor = [UIColor grayColor];
    // 圆角
    bigView.layer.masksToBounds = YES;
    bigView.layer.cornerRadius = 10;
    [self addSubview:bigView];
    
    
}

- (void)setUpWithTextfield:(UITextField *)textfield placeholder:(NSString *)placeholder {
    
    textfield.layer.borderColor = [[UIColor whiteColor] CGColor];
    textfield.layer.borderWidth = 1;
    textfield.layer.cornerRadius = 10;
    textfield.layer.masksToBounds = YES;
    textfield.placeholder = placeholder;
    
    
   
    
}


- (void)setUpWithphotoHolderView:(UIImageView *)photoHolderView {
    
    photoHolderView.image = [UIImage imageNamed:@"user1"];
    
    photoHolderView.layer.masksToBounds = YES;
    photoHolderView.layer.cornerRadius = self.photoHolderView.frame.size.width / 2;
    
    [self.bigView addSubview:photoHolderView];
}













@end
